#! /usr/bin/env python
# -*- coding: utf-8 -*-
# __author__ = "Q1mi"
# Date: 2020/8/8

from itsdangerous import TimedJSONWebSignatureSerializer as Jwt
from django.conf import settings


class Tokens:
    def set_token(self,userinfo):
      #  print("userinfo",userinfo)
        # serializer = Jwt(秘钥, 有效期秒)
        serializer = Jwt(settings.SECRET_KEY, settings.TOKEN_OUT_TIME)
        # serializer.dumps(数据), 返回bytes类型
        token = serializer.dumps(userinfo)
        return token.decode()